package com.eshop.common.web.param;

import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiModel;
import java.io.Serializable;

@ApiModel("查询参数对象")
public abstract class QueryParam implements Serializable
{
    private static final long serialVersionUID = -3263921252635611410L;
    @ApiModelProperty("页码,默认为1")
    private Integer page;
    @ApiModelProperty("页大小,默认为10")
    private Integer limit;
    @ApiModelProperty("搜索字符串")
    private String keyword;
    
    @ApiModelProperty("当前第几页")
    public void setCurrent(final Integer current) {
        if (current == null || current <= 0) {
            this.page = 1;
        }
        else {
            this.page = current;
        }
    }
    
    public void setSize(final Integer size) {
        if (size == null || size <= 0) {
            this.limit = 10;
        }
        else {
            this.limit = size;
        }
    }
    
    public QueryParam() {
        this.page = 1;
        this.limit = 10;
    }
    
    public Integer getPage() {
        return this.page;
    }
    
    public Integer getLimit() {
        return this.limit;
    }
    
    public String getKeyword() {
        return this.keyword;
    }
    
    public void setPage(final Integer page) {
        this.page = page;
    }
    
    public void setLimit(final Integer limit) {
        this.limit = limit;
    }
    
    public void setKeyword(final String keyword) {
        this.keyword = keyword;
    }
    
    @Override
    public boolean equals(final Object o) {
        if (o == this) {
            return true;
        }
        if (!(o instanceof QueryParam)) {
            return false;
        }
        final QueryParam other = (QueryParam)o;
        if (!other.canEqual(this)) {
            return false;
        }
        final Object this$page = this.getPage();
        final Object other$page = other.getPage();
        Label_0065: {
            if (this$page == null) {
                if (other$page == null) {
                    break Label_0065;
                }
            }
            else if (this$page.equals(other$page)) {
                break Label_0065;
            }
            return false;
        }
        final Object this$limit = this.getLimit();
        final Object other$limit = other.getLimit();
        Label_0102: {
            if (this$limit == null) {
                if (other$limit == null) {
                    break Label_0102;
                }
            }
            else if (this$limit.equals(other$limit)) {
                break Label_0102;
            }
            return false;
        }
        final Object this$keyword = this.getKeyword();
        final Object other$keyword = other.getKeyword();
        if (this$keyword == null) {
            if (other$keyword == null) {
                return true;
            }
        }
        else if (this$keyword.equals(other$keyword)) {
            return true;
        }
        return false;
    }
    
    protected boolean canEqual(final Object other) {
        return other instanceof QueryParam;
    }
    
    @Override
    public int hashCode() {
        final int PRIME = 59;
        int result = 1;
        final Object $page = this.getPage();
        result = result * 59 + (($page == null) ? 43 : $page.hashCode());
        final Object $limit = this.getLimit();
        result = result * 59 + (($limit == null) ? 43 : $limit.hashCode());
        final Object $keyword = this.getKeyword();
        result = result * 59 + (($keyword == null) ? 43 : $keyword.hashCode());
        return result;
    }
    
    @Override
    public String toString() {
        return "QueryParam(page=" + this.getPage() + ", limit=" + this.getLimit() + ", keyword=" + this.getKeyword() + ")";
    }
}
